import 'package:mobile_app.core/core/domain/entities/learning_content/lexical_item/lexical_item.dart';
import 'package:mobile_app.home.core/core/domain/entities/card_actions/editing_card_action.dart';
import 'package:mobile_app.home.core/core/domain/helpers/is_editing_card_action_reasonable/helper.dart';

abstract class CreateEditingCardActionIfReasonable {
  EditingCardAction? call({
    required LexicalItem lexicalItem,
  });
}

class CreateEditingCardActionIfReasonableImpl implements CreateEditingCardActionIfReasonable {
  const CreateEditingCardActionIfReasonableImpl({
    required IsEditingCardActionReasonable isEditingCardActionReasonable,
  }) : _isEditingCardActionReasonable = isEditingCardActionReasonable;

  final IsEditingCardActionReasonable _isEditingCardActionReasonable;

  @override
  EditingCardAction? call({
    required LexicalItem lexicalItem,
  }) {
    final cardActionReasonable = _isEditingCardActionReasonable(
      lexicalItem: lexicalItem,
    );

    if (!cardActionReasonable) {
      return null;
    }

    return const EditingCardAction();
  }
}
